package com.holic.spring.graphql.controller;

import com.holic.spring.graphql.entity.Project;
import com.holic.spring.graphql.entity.ProjectStatus;
import com.holic.spring.graphql.entity.User;
import com.holic.spring.graphql.model.ProjectInput;
import org.springframework.graphql.data.method.annotation.Argument;
import org.springframework.graphql.data.method.annotation.Arguments;
import org.springframework.graphql.data.method.annotation.MutationMapping;
import org.springframework.stereotype.Controller;

import java.util.UUID;

/**
 * @ClassName ModifyController
 * @Description
 * @Author Neil
 * @Date 2024/11/11 11:34
 * @Version V1.0
 **/
@Controller
public class ModifyController {

    @MutationMapping
    public Project createProject(@Argument String name, @Argument String repositoryUrl) {
        Project project = new Project();
        project.setSlug("111");
        project.setName("holic-spring-graphql");
        project.setRepositoryUrl(repositoryUrl);
        project.setStatus(ProjectStatus.ACTIVE);

        User responsible = new User();
        responsible.setId("123");
        responsible.setCode("12345");
        responsible.setName("张三");
        responsible.setDepartment("IT");

        project.setResponsible(responsible);
        return project;
    }

    @MutationMapping
    public Project modifyProject(@Arguments ProjectInput input) {
        Project project = new Project();
        project.setSlug(input.getSlug());
        project.setName(input.getName());
        project.setRepositoryUrl(input.getRepositoryUrl());
        project.setStatus(ProjectStatus.ACTIVE);

        User responsible = new User();
        responsible.setId("123");
        responsible.setCode("12345");
        responsible.setName("张三");
        responsible.setDepartment("IT");

        project.setResponsible(responsible);
        return project;
    }

}
